package com.huiyun.project.im.api.client.feign;


import com.huiyun.project.common.core.domain.R;
import com.huiyun.project.common.core.domain.req.SimpleCommonReq;
import com.huiyun.project.im.api.client.vo.req.AppTokenReq;
import com.huiyun.project.im.api.client.vo.req.LoginReq;
import com.huiyun.project.im.api.client.vo.resp.TokenResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * im对外 feign接口
 */
@FeignClient(contextId = "remoteApiImService", value = "huiyun-im-server-biz")
public interface RemoteApiImService {


    /**
     * 获取token
     *
     * @return r
     */
    @PostMapping("im/api/im/{version}/token")
    R<TokenResp> getToken(@PathVariable("version") String version,
                          @RequestBody AppTokenReq appTokenReq);

    /**
     * 用户登录 账户 密码 appgroup
     *
     * @param version //     * @param username
     *                //     * @param password
     *                //     * @param appKey
     *                //     * @param device
     * @return
     */
    @GetMapping("im/api/im/{version}/login")
    R<TokenResp> login(@PathVariable("version") String version,
                       @SpringQueryMap LoginReq loginReq);


    /**
     * 检测IM的token并刷新,一般用于打开应用,并且有accessToken的时候
     *
     * @return
     */
    @GetMapping("im/api/im/{version}/checkLogin")
    R<TokenResp> checkLogin(@PathVariable("version") String version,@RequestParam("username") String username, @RequestParam("appGroupId") String appGroupId ,@RequestParam("accessToken") String accessToken);


    /**
     * 刷新登录token
     *
     * @return r
     */
    @PostMapping("im/api/im/{version}/refreshLogin")
    R<TokenResp> refreshLogin(@PathVariable("version") String version,
                              @RequestBody SimpleCommonReq commonReq,@RequestHeader("ImAuthorization") String token);
}
